package com.gxa.meiye.admin.platform.controller;



import com.gxa.meiye.admin.platform.pojo.vo.UpdateUserStatusVo;
import com.gxa.meiye.admin.platform.pojo.vo.UserVo;
import com.gxa.meiye.admin.platform.service.UserService;
import com.gxa.meiye.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/platform/user")
public class UserController {

    @Autowired
    private UserService userService;

//    @ApiOperation("测试方法")
//    @PostMapping("/test")
//    public void testSwag(){
//        System.out.println("test");
//    }

//    @RequiresPermissions("cust:select")
    @ApiOperation("消费者列表")
    @GetMapping("/list")
    public Map userList(){
        List<UserVo> userVos = userService.selectUserList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(userVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }

    @ApiOperation("修改消费者状态")
    @PostMapping("/updateStatus")
    public Map updateStatus(@RequestBody UpdateUserStatusVo userVo){
        userService.updateStatus(userVo);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("修改成功");
        return jsonResult.getMap();
    }

    @ApiOperation("查询消费者")
    @PostMapping("/selectUsers")
    public Map selectUsers(String select){
        List<UserVo> userVos = userService.selectUsers(select);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("修改成功");
        jsonResult.setData(userVos);
        return jsonResult.getMap();
    }
}
